package cn.yto.print.config;

import cn.yto.print.model.response.PrintTaskResponse;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;

public class PrintFutureContext {

    private static final ConcurrentHashMap<String, CompletableFuture<PrintTaskResponse>> RESPONSE_FUTURE_MAP = new ConcurrentHashMap<>();

    public static CompletableFuture<PrintTaskResponse> getResponseFuture(String taskId) {
        return RESPONSE_FUTURE_MAP.get(taskId);
    }

    public static CompletableFuture<PrintTaskResponse> addResponseFuture(String taskId, CompletableFuture<PrintTaskResponse> responseFuture) {
        return RESPONSE_FUTURE_MAP.put(taskId, responseFuture);
    }

    public static void removeResponseFuture(String taskId) {
        RESPONSE_FUTURE_MAP.remove(taskId);
    }

}
